go/types.Checker.errorf (method)
192 uses
go/types (current package)
assignments.go#L38: check.errorf(x, IncompatibleAssign, "cannot assign %s to %s in %s", x, T, context)
assignments.go#L53: check.errorf(x, UntypedNilUse, "use of untyped nil in %s", context)
assignments.go#L63: check.errorf(x, UntypedNilUse, "use of untyped nil in %s", context)
assignments.go#L98: check.errorf(x, WrongTypeArgCount, "cannot use generic function %s without instantiation in %s", x, context)
assignments.go#L113: check.errorf(x, code, "cannot use %s as %s value in %s: %s", x, T, context, cause)
assignments.go#L115: check.errorf(x, code, "cannot use %s as %s value in %s", x, T, context)
assignments.go#L131: check.errorf(x, InvalidConstInit, "%s is not constant", x)
assignments.go#L171: check.errorf(x, UntypedNilUse, "use of untyped nil in %s", context)
assignments.go#L238: check.errorf(&x, UnaddressableFieldAssign, "cannot assign to struct field %s in map", ExprString(x.expr))
assignments.go#L242: check.errorf(&x, UnassignableOperand, "cannot assign to %s (neither addressable nor a map index expression)", x.expr)
assignments.go#L361: check.errorf(rhs0, WrongAssignCount, "assignment mismatch: %s but %s returns %s", vars, call.Fun, vals)
assignments.go#L365: check.errorf(rhs0, WrongAssignCount, "assignment mismatch: %s but %s", vars, vals)
assignments.go#L540: check.errorf(lhs, BadDecl, "non-name %s on left side of :=", lhs)
assignments.go#L548: check.errorf(lhs, RepeatedDecl, "%s repeated on left side of :=", lhs)
assignments.go#L565: check.errorf(lhs, UnassignableOperand, "cannot assign to %s", lhs)
builtins.go#L29: check.errorf(dddErrPos(call),
builtins.go#L81: check.errorf(argErrPos(call), WrongArgCount, invalidOp+"%s arguments for %v (expected %d, found %d)", msg, call, bin.nargs, nargs)
builtins.go#L112: check.errorf(x, InvalidAppend, "first argument to append must be a slice; %s", cause)
builtins.go#L216: check.errorf(x, code, invalidArg+"%s for built-in %s", x, bin.name)
builtins.go#L239: check.errorf(x, InvalidClear, invalidArg+"cannot clear %s: argument must be (or constrained by) map or slice", x)
builtins.go#L255: check.errorf(x, InvalidClose, invalidOp+"cannot close non-channel %s", x)
builtins.go#L259: check.errorf(x, InvalidClose, invalidOp+"cannot close receive-only channel %s", x)
builtins.go#L322: check.errorf(x, InvalidComplex, invalidOp+"%v (mismatched types %s and %s)", call, x.typ, y.typ)
builtins.go#L344: check.errorf(x, InvalidComplex, invalidArg+"arguments have type %s, expected floating-point", x.typ)
builtins.go#L373: check.errorf(x, InvalidCopy, invalidArg+"copy expects slice arguments; found %s and %s", x, y)
builtins.go#L378: check.errorf(x, InvalidCopy, invalidArg+"arguments to copy %s and %s have different element types %s and %s", x, y, dst.elem, src.elem)
builtins.go#L397: check.errorf(x, InvalidDelete, invalidArg+"%s is not a map", x)
builtins.go#L401: check.errorf(x, InvalidDelete, invalidArg+"maps of %s must have identical key types", x)
builtins.go#L468: check.errorf(x, code, invalidArg+"argument has type %s, expected complex type", x.typ)
builtins.go#L506: check.errorf(arg0, InvalidMake, invalidArg+"cannot make %s: no core type", arg0)
builtins.go#L509: check.errorf(arg0, InvalidMake, invalidArg+"cannot make %s; type must be slice, map, or channel", arg0)
builtins.go#L513: check.errorf(call, WrongArgCount, invalidOp+"%v expects %d or %d arguments; found %d", call, min, min+1, nargs)
builtins.go#L552: check.errorf(a, InvalidMinMaxOperand, invalidArg+"%s cannot be ordered", a)
builtins.go#L564: check.errorf(a, MismatchedTypes, invalidArg+"mismatched types %s (previous argument) and %s (type of %s)", x.typ, a.typ, a.expr)
builtins.go#L713: check.errorf(arg0, BadOffsetofSyntax, invalidArg+"%s is not a selector expression", arg0)
builtins.go#L728: check.errorf(x, MissingFieldOrMethod, invalidArg+"%s has no single field %s", base, sel)
builtins.go#L735: check.errorf(arg0, InvalidOffsetof, invalidArg+"%s is a method value", arg0)
builtins.go#L739: check.errorf(x, InvalidOffsetof, invalidArg+"field %s is embedded via a pointer in %s", sel, base)
builtins.go#L767: check.errorf(x, TypeTooLarge, "%s is too large", x)
builtins.go#L791: check.errorf(x, TypeTooLarge, "%s is too large", x)
builtins.go#L806: check.errorf(x, InvalidUnsafeSlice, invalidArg+"%s is not a pointer", x)
builtins.go#L827: check.errorf(x, InvalidUnsafeSliceData, invalidArg+"%s is not a slice", x)
builtins.go#L877: check.errorf(x, Test, invalidArg+"%s is not a boolean constant", x)
builtins.go#L881: check.errorf(x, Test, "internal error: value of %s should be a boolean constant", x)
builtins.go#L885: check.errorf(call, Test, "%v failed", call)
call.go#L67: check.errorf(ix.indices[got-1], WrongTypeArgCount, "got %d type arguments but want %d", got, want)
call.go#L207: check.errorf(inNode(call, call.Rparen), WrongArgCount, "missing argument in conversion to %s", T)
call.go#L212: check.errorf(call.Args[0], BadDotDotDotSyntax, "invalid use of ... in conversion to %s", T)
call.go#L217: check.errorf(call, MisplacedConstraintIface, "cannot use interface %s in conversion (contains specific type constraints or is comparable)", T)
call.go#L225: check.errorf(call.Args[n-1], WrongArgCount, "too many arguments in conversion to %s", T)
call.go#L251: check.errorf(x, InvalidCall, invalidOp+"cannot call non-function %s", x)
call.go#L277: check.errorf(xlist[want], WrongTypeArgCount, "got %d type arguments but want %d", got, want)
call.go#L486: check.errorf(inNode(call, call.Ellipsis), InvalidDotDotDot, "cannot use ... with %d-valued %s", nargs, call.Args[0])
call.go#L513: check.errorf(inNode(call, call.Ellipsis), NonVariadicDotDotDot, "cannot use ... in call to non-variadic %s", call.Fun)
call.go#L621: check.errorf(err.posn(), CannotInferTypeArgs, "in call to %s, %s", call.Fun, err.msg())
call.go#L716: check.errorf(e.Sel, UndeclaredImportedName, "undefined: %s", ast.Expr(e)) // cast to ast.Expr to silence vet
call.go#L725: check.errorf(e.Sel, UndeclaredImportedName, "undefined: %s", ast.Expr(e))
call.go#L730: check.errorf(e.Sel, UnexportedName, "name %s not exported by package %s", sel, pkg.name)
call.go#L783: check.errorf(e.Sel, UncalledBuiltin, "invalid use of %s in selector expression", x)
call.go#L804: check.errorf(e.Sel, NotAType, "%s is not a type", ast.Expr(e))
call.go#L817: check.errorf(e.Sel, AmbiguousSelector, "ambiguous selector %s.%s", x.expr, sel)
call.go#L823: check.errorf(e.Sel, InvalidMethodExpr, "invalid method expression %s.%s (needs pointer receiver (*%s).%s)", x.typ, sel, x.typ, sel)
call.go#L825: check.errorf(e.Sel, InvalidMethodExpr, "cannot call pointer method %s on %s", sel, x.typ)
call.go#L837: check.errorf(e.Sel, MissingFieldOrMethod, "%s.%s undefined (%s)", x.expr, sel, why)
call.go#L850: check.errorf(e.Sel, MissingFieldOrMethod, "%s.%s undefined (type %s has no method %s)", x.expr, sel, x.typ, sel)
check.go#L365: check.errorf(atPos(file.Package), MismatchedPkgName, "package %s; expected package %s", name, pkg.name)
check.go#L379: check.errorf(files[0], TooNew, "package requires newer Go version %v (application built with %v)",
check.go#L410: check.errorf(file.Name, TooNew, "file requires newer Go version %v (application built with %v)", fileVersion, go_current)
const.go#L49: check.errorf(atPos(opPos), InvalidConstVal, "constant %soverflow", op)
const.go#L285: check.errorf(x, code, msg, x, target)
conversions.go#L52: check.errorf(x, InvalidConversion, "constant %s overflows %s", x.val, T)
conversions.go#L91: check.errorf(x, InvalidConversion, "cannot convert %s to type %s: %s", x, T, cause)
conversions.go#L93: check.errorf(x, InvalidConversion, "cannot convert %s to type %s", x, T)
decl.go#L324: check.errorf(obj, InvalidDeclCycle, "invalid recursive type: %s refers to itself", name(obj))
decl.go#L326: check.errorf(obj, InvalidDeclCycle, "invalid cycle in declaration: %s refers to itself", name(obj))
decl.go#L417: check.errorf(s, InvalidSyntaxTree, "invalid token %s", d.Tok)
decl.go#L422: check.errorf(s, InvalidSyntaxTree, "unknown ast.Spec node %T", s)
decl.go#L428: check.errorf(d, InvalidSyntaxTree, "unknown ast.Decl node %T", d)
decl.go#L453: check.errorf(typ, InvalidConstType, "invalid constant type %s", t)
decl.go#L791: check.errorf(m, DuplicateMethod, "method %s.%s already declared at %v", obj.Name(), m.name, alt.Pos())
decl.go#L793: check.errorf(m, DuplicateMethod, "method %s.%s already declared", obj.Name(), m.name)
decl.go#L971: check.errorf(d.node(), InvalidSyntaxTree, "unknown ast.Decl node %T", d.node())
errors.go#L240: func (check *Checker) errorf(at positioner, code Code, format string, args ...any) {
expr.go#L76: check.errorf(x, UndefinedOp, invalidOp+"operator %s not defined on %s", op, x)
expr.go#L80: check.errorf(x, InvalidSyntaxTree, "unknown operator %s", op)
expr.go#L141: check.errorf(x, UnaddressableOperand, invalidOp+"cannot take address of %s", x)
expr.go#L152: check.errorf(x, InvalidReceive, invalidOp+"cannot receive from %s (no core type)", x)
expr.go#L158: check.errorf(x, InvalidReceive, invalidOp+"cannot receive from non-channel %s", x)
expr.go#L163: check.errorf(x, InvalidReceive, invalidOp+"cannot receive from send-only channel %s", x)
expr.go#L323: check.errorf(x, InvalidShiftOperand, invalidOp+"shifted operand %s (type %s) must be integer", x, typ)
expr.go#L568: check.errorf(x, code, "invalid case %s in switch on %s (%s)", x.expr, y.expr, cause) // error position always at 1st operand
expr.go#L570: check.errorf(errOp, code, invalidOp+"%s %s %s (%s)", x.expr, op, y.expr, cause)
expr.go#L604: check.errorf(x, InvalidShiftOperand, invalidOp+"shifted operand %s must be integer", x)
expr.go#L619: check.errorf(y, InvalidShiftCount, invalidOp+"negative shift count %s", y)
expr.go#L650: check.errorf(y, InvalidShiftCount, invalidOp+"shift count %s must be integer", y)
expr.go#L671: check.errorf(y, InvalidShiftCount, invalidOp+"invalid shift count %s", y)
expr.go#L722: check.errorf(x, InvalidShiftOperand, invalidOp+"shifted operand %s must be integer", x)
expr.go#L792: check.errorf(posn, MismatchedTypes, invalidOp+"%s (mismatched types %s and %s)", e, x.typ, y.typ)
expr.go#L794: check.errorf(posn, MismatchedTypes, invalidOp+"%s %s= %s (mismatched types %s and %s)", lhs, op, rhs, x.typ, y.typ)
expr.go#L986: check.errorf(x.expr, WrongTypeArgCount, "cannot use generic %s %s without instantiation", what, x.expr)
expr.go#L1072: check.errorf(x, InvalidAssert, invalidOp+"cannot use type assertion on type parameter value %s", x)
expr.go#L1076: check.errorf(x, InvalidAssert, invalidOp+"%s is not an interface", x)
expr.go#L1103: check.errorf(x, InvalidIndirection, invalidOp+"cannot indirect %s", x)
expr.go#L1107: check.errorf(x, InvalidIndirection, invalidOp+"pointers of %s must have identical base types", x)
expr.go#L1214: check.errorf(e, ImpossibleAssert, "impossible type switch case: %s\n\t%s cannot have dynamic type %s %s", e, x, T, cause)
expr.go#L1218: check.errorf(e, ImpossibleAssert, "impossible type assertion: %s\n\t%s does not implement %s %s", e, T, x.typ, cause)
expr.go#L1315: check.errorf(x, code, msg, x)
expr.go#L1326: check.errorf(x, TooManyValues, "multiple-value %s in single-value context", x)
index.go#L188: check.errorf(x, NonIndexableOperand, invalidOp+"cannot index %s", x)
index.go#L222: check.errorf(x, NonSliceableOperand, invalidOp+"cannot slice %s: %s has no core type", x, x.typ)
index.go#L252: check.errorf(x, NonSliceableOperand, invalidOp+"cannot slice %s (value not addressable)", x)
index.go#L271: check.errorf(x, NonSliceableOperand, invalidOp+"cannot slice %s", x)
index.go#L322: check.errorf(at, SwappedSliceIndices, "invalid slice indices: %d < %d", y, x)
index.go#L335: check.errorf(expr.orig, InvalidSyntaxTree, "index expression %v with 0 indices", expr)
index.go#L370: check.errorf(&x, InvalidIndex, invalidArg+"index %s out of bounds [0:%d]", x.val.String(), max)
index.go#L391: check.errorf(x, code, invalidArg+"%s %s must be integer", what, x)
index.go#L398: check.errorf(x, code, invalidArg+"%s %s must not be negative", what, x)
index.go#L404: check.errorf(x, code, invalidArg+"%s %s overflows int", what, x)
initorder.go#L173: check.errorf(obj, InvalidInitCycle, "initialization cycle: %s refers to itself", obj.Name())
interface.go#L186: check.errorf(f.Type, InvalidSyntaxTree, "%s is not a method signature", typ)
labels.go#L37: check.errorf(jmp.Label, code, msg, name)
labels.go#L193: check.errorf(s.Label, MisplacedLabel, "invalid break label %s", name)
labels.go#L208: check.errorf(s.Label, MisplacedLabel, "invalid continue label %s", name)
labels.go#L220: check.errorf(s, InvalidSyntaxTree, "branch statement: %s %s", s.Tok, name)
literals.go#L63: check.errorf(e, InvalidConstVal, "excessively long constant: %s... (%d chars)", e.Value[:10], len(e.Value))
literals.go#L74: check.errorf(e, InvalidConstVal, "malformed constant: %s", e.Value)
literals.go#L106: check.errorf(e, InvalidSyntaxTree, "invalid function literal %v", e)
literals.go#L179: check.errorf(kv, InvalidLitField, "invalid field name %s in struct literal", kv.Key)
literals.go#L198: check.errorf(kv, DuplicateLitField, "duplicate field name %s in struct literal", key.Name)
literals.go#L212: check.errorf(x, InvalidStructLit, "too many values in struct literal of type %s", base)
literals.go#L218: check.errorf(x, UnexportedLitField, "implicit assignment to unexported field %s in struct literal of type %s", fld.name, base)
literals.go#L225: check.errorf(inNode(e, e.Rbrace), InvalidStructLit, "too few values in struct literal of type %s", base)
literals.go#L309: check.errorf(x, DuplicateLitKey, "duplicate key %s in map literal", x.val)
literals.go#L339: check.errorf(e, InvalidLit, "invalid composite literal%s type %s%s", qualifier, typ, cause)
literals.go#L366: check.errorf(e, InvalidLitIndex, "index %s must be integer constant", kv.Key)
literals.go#L371: check.errorf(e, OversizeArrayLit, "index %d is out of bounds (>= %d)", index, length)
literals.go#L379: check.errorf(e, DuplicateLitKey, "duplicate index %d in array or slice literal", index)
resolver.go#L73: check.errorf(n, code, "extra init expr %s", n)
resolver.go#L77: check.errorf(s, code, "extra init expr at %s", check.fset.Position(init.Pos()))
resolver.go#L82: check.errorf(n, code, "missing init expr for %s", n)
resolver.go#L179: check.errorf(at, BrokenImport, "could not import %s (%s)", path, err)
resolver.go#L270: check.errorf(d.spec.Path, BadImportPath, "invalid import path (%s)", err)
resolver.go#L537: check.errorf(arg, BadDecl, "receiver type parameter %s must be an identifier", arg)
signature.go#L189: check.errorf(rbase, InvalidRecv, "cannot define new methods on instantiated type %s", g)
signature.go#L209: check.errorf(rbase, InvalidRecv, "cannot define new methods on generic alias type %s", t)
signature.go#L218: check.errorf(rbase, InvalidRecv, "%s", cause)
signature.go#L255: check.errorf(rbase, BadRecv, "receiver declares %s, but receiver base type declares %d", got, len(baseTParams))
signature.go#L438: check.errorf(pos, InvalidRecv, "cannot define new methods on non-local type %s", rtyp)
signature.go#L456: check.errorf(pos, InvalidRecv, "invalid receiver type %s (%s)", rtyp, cause)
signature.go#L459: check.errorf(pos, InvalidRecv, "cannot define new methods on non-local type %s", rtyp)
signature.go#L461: check.errorf(pos, InvalidRecv, "invalid receiver type %s", recv.typ)
stmt.go#L145: check.errorf(d, DuplicateDefault, "multiple defaults (first at %s)", check.fset.Position(first.Pos()))
stmt.go#L190: check.errorf(&x, code, "%s %s %s", keyword, msg, &x)
stmt.go#L460: check.errorf(&x, code, "%s %s", &x, msg)
stmt.go#L471: check.errorf(inNode(s, s.Arrow), InvalidSend, invalidOp+"cannot send to %s: no core type", &ch)
stmt.go#L476: check.errorf(inNode(s, s.Arrow), InvalidSend, invalidOp+"cannot send to non-channel %s", &ch)
stmt.go#L480: check.errorf(inNode(s, s.Arrow), InvalidSend, invalidOp+"cannot send to receive-only channel %s", &ch)
stmt.go#L493: check.errorf(inNode(s, s.TokPos), InvalidSyntaxTree, "unknown inc/dec operation %s", s.Tok)
stmt.go#L503: check.errorf(s.X, NonNumericIncDec, invalidOp+"%s%s (non-numeric type %s)", s.X, s.Tok, x.typ)
stmt.go#L531: check.errorf(inNode(s, s.TokPos), MultiValAssignOp, "assignment operation %s requires single-valued expressions", s.Tok)
stmt.go#L536: check.errorf(atPos(s.TokPos), InvalidSyntaxTree, "unknown assignment operation %s", s.Tok)
stmt.go#L606: check.errorf(s, InvalidSyntaxTree, "branch statement: %s", s.Tok)
stmt.go#L650: check.errorf(&x, InvalidExprSwitch, "cannot switch on %s (%s is not comparable)", &x, x.typ)
stmt.go#L743: check.errorf(&x, InvalidTypeSwitch, "cannot use type switch on type parameter value %s", &x)
stmt.go#L747: check.errorf(&x, InvalidTypeSwitch, "%s is not an interface", &x)
stmt.go#L948: check.errorf(lhs, InvalidSyntaxTree, "cannot declare %s", lhs)
struct.go#L129: check.errorf(f.Type, InvalidSyntaxTree, "embedded field type %s has no name", f.Type)
struct.go#L218: check.errorf(t, InvalidSyntaxTree, "incorrect tag syntax: %q", t.Value)
typeset.go#L406: check.errorf(atPos(pos), InvalidUnion, "cannot handle more than %d union terms (implementation limitation)", maxTermCount)
typexpr.go#L31: check.errorf(e, UndeclaredName, "undefined: %s", e.Name)
typexpr.go#L53: check.errorf(e, NotAType, "%s is not a type", obj.Name())
typexpr.go#L90: check.errorf(e, InvalidPkgUse, "use of package %s not in selector", obj.name)
typexpr.go#L112: check.errorf(e, InvalidDeclCycle, "invalid use of type alias %s in recursive type (see go.dev/issue/50729)", obj.name)
typexpr.go#L196: check.errorf(e, WrongTypeArgCount, "cannot use generic type %s without instantiation", typ)
typexpr.go#L268: check.errorf(&x, NotAType, "%s used as type", &x)
typexpr.go#L270: check.errorf(&x, NotAType, "%s is not a type", &x)
typexpr.go#L285: check.errorf(&x, NotAType, "%s used as type", &x)
typexpr.go#L287: check.errorf(&x, NotAType, "%s is not a type", &x)
typexpr.go#L381: check.errorf(e.Key, IncomparableMapKey, "invalid map key type %s%s", typ.key, why)
typexpr.go#L400: check.errorf(e, InvalidSyntaxTree, "unknown channel direction %d", e.Dir)
typexpr.go#L409: check.errorf(e0, NotAType, "%s is not a type", e0)
typexpr.go#L451: check.errorf(ix.orig, NotAGenericType, invalidOp+"%s (%s)", ix.orig, cause)
typexpr.go#L516: check.errorf(name, InvalidArrayLen, "undefined array length %s or missing type constraint", name.Name)
typexpr.go#L520: check.errorf(name, InvalidArrayLen, "invalid array length %s", name.Name)
typexpr.go#L529: check.errorf(&x, InvalidArrayLen, "array length %s must be constant", &x)
typexpr.go#L550: check.errorf(&x, InvalidArrayLen, msg, &x)
union.go#L71: check.errorf(x, InvalidUnion, "cannot handle more than %d union terms (implementation limitation)", maxTermCount)
union.go#L101: check.errorf(tlist[i], InvalidUnion, "invalid use of ~ (%s is an interface)", t.typ)
union.go#L106: check.errorf(tlist[i], InvalidUnion, "invalid use of ~ (underlying type of %s is %s)", t.typ, u)
union.go#L119: check.errorf(tlist[i], InvalidUnion, "cannot use %s in union (%s contains methods)", t, t)
union.go#L123: check.errorf(tlist[i], InvalidUnion, "cannot use %s in union (%s embeds comparable)", t, t)
union.go#L154: check.errorf(x, MisplacedTypeParam, "type in term %s cannot be a type parameter", tx)